////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//  Filename:    FunkyMonkeyGuts.h                                            //
//  Developer:   Phillip Sharpless                                            //
//  Create date: 07/24/2007                                                   //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//  Description: This is the class declaration for the slot gut of the        //
//               Australian Slot machine called Funky Monkey                  //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
//        Copyright (c) 2007 - Realtime Gaming.  All rights reserved.         //
////////////////////////////////////////////////////////////////////////////////

#if !defined(__FunkyMonkeyGuts_H__)
#define __FunkyMonkeyGuts_H__

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "slotguts.h"
#include "getrand.h"

class FunkyMonkeyGuts : public SlotGuts
{
	// Shared enums between client and server
	#include "FunkyMonkeyCommon.h"

public:
	FunkyMonkeyGuts();

	virtual ~FunkyMonkeyGuts();

	virtual void classifyStops( SpinLine* spinline, uint8* stops, uint8 bet, uint8 line,
		uint8& rtnresult, uint8& multiplier );

	virtual void classifyScatters( SlotSpin *spin );

    virtual bool8 isValidGuts();

    virtual void getGameModeMultiplierAndNoteId( uint8& nGameModeMultiplier, uint8& nNoteId );

	virtual bool8 processClientData(uint8 bonusGameType, int32 bonusDataCount, int32 *bonusData);

protected:

    virtual bool8 hasSavedGames();

	void initializePickFeatureGame();

	void setFeatureGamePickPosition(int32 nPick);
	int32 getFeatureGamePickPosition() const;		

	void setFeatureGameFreeSpinsWon(int32 nFreeSpins);
	int32 getFeatureGameFreeSpinsWon() const;

	void setFreeGameMultiplier(int32 nMultiplier);
	int32 getFreeGameMultiplier() const;

	virtual void preSpinClassifyResults( SlotSpin *spin );

	virtual void initDebugFunctionMap();

	enum
	{
		EVT_DEBUG_FUNCTION_8_SPINS = BEGIN_SUB_MODIFY_NEXT_RESULT_FUNCTION_RANGE,
		EVT_DEBUG_FUNCTION_10_SPINS,
		EVT_DEBUG_FUNCTION_12_SPINS,
		EVT_DEBUG_FUNCTION_15_SPINS,
		EVT_DEBUG_FUNCTION_20_SPINS,
		EVT_DEBUG_FUNCTION_25_SPINS,
	};

	void DebugFeature_8_Spins(SlotSpin *spin );
	void DebugFeature_10_Spins(SlotSpin *spin );
	void DebugFeature_12_Spins(SlotSpin *spin );
	void DebugFeature_15_Spins(SlotSpin *spin );
	void DebugFeature_20_Spins(SlotSpin *spin );
	void DebugFeature_25_Spins(SlotSpin *spin );

	static int g_nDebugFreeSpins;

private:

	// Helpful lookup arrays.
	static SpinResult m_aLineWinSpinResults[][6];
	static SpinResult m_aScatterWinSpinResults[6];

	// Inline functions to use with the arrays that also do
	// bounds checking.
	static SpinResult lookupLineWinSpinResult(uint8 nIconType, uint8 nCount )
	{
		if ( nIconType < NUM_VALID_ICONS && nCount < 6 )
		{
			return m_aLineWinSpinResults[ nIconType ][ nCount ];
		}

		ASSERT( false );
		return EVT_INVALID;
	}

	static SpinResult lookupScatterWinSpinResult( uint8 nCount )
	{
		if ( nCount < 6 )
		{
			return m_aScatterWinSpinResults[ nCount ];
		}

		ASSERT( false );
		return EVT_INVALID;
	}

	//helper functions for classifyStops
	SpinResult getLineWinResultWithPossibleSubstitution(
		uint8* stops, uint8 testIcon, bool& bFMSubstitution, bool& bFSubstitution, bool& bMSubstitution ) const;

	//helper functions for classifyScatters
	void tryForJackpot( SlotSpin* spin );

	SpinResult getScatterWinResult(SlotSpin* spin, int32& scatterPositions) const;

	void evaluateScatterWin( SlotSpin* spin, SpinResult srScatterResult, int32 scatterPositions);
	void addScatterNearMiss(SlotSpin* spin, int32 scatterPositionsLTR, int32 scatterPositionsRTL);
	void evaluateFeatureTrigger( SlotSpin* spin, SpinResult srScatterResult, int32 scatterPositions);

	void checkForMultipliersWon(SlotSpin *spin, bool AddScatters);

	int m_nHit10XMultiplier;
};


#endif // !defined(__FunkyMonkeyGuts_H__)
